package main

import "fmt"

func main2() {

	//var a [5]int
	//a[0] = 1
	//a[1] = 2
	//a[2] = 3
	//a[3] = 4
	//a[4] = 5
	//fmt.Printf("%v\n", a)
	////下标访问
	//fmt.Println("访问下标数组下标3的值", a[3])
	////范围访问 1
	//fmt.Println("访问下标数组下标3到末尾的值", a[3:])
	////范围访问 2
	//fmt.Println("访问下标数组下标3到末尾的值", a[:3])
	////访问数组越界
	////fmt.Println("越界--》", a[5])
	////所有的值
	//fmt.Println("所有的值", a[:])

	//长度不固定的
	//var str := [...]string{"a","b","c","d"}
	//str := [...]string{"a", "b", "c", "d"}
	//str[0] = "a"
	//str[1] = "b"
	//str[2] = "c"
	//str[4] = "d"

	//fmt.Println("数组的长度是", len(str))
	//
	//for i := 0; i < len(str); i++ {
	//	fmt.Println("下标", i, "--->值是：", str[i])
	//}

	//切片
	//var users []string
	//
	//var myUsers []string
	//
	//users = append(users, "xiaoZhang", "小李", "小王")
	//fmt.Printf("user len:%d\n", len(users))
	//fmt.Printf("user cap:%d\n", cap(users))
	//myUsers = append(users, "my-李磊", "my-小李", "my-小王")
	//myUsers = append(myUsers, "my-李磊3")
	////myUsers = append(users, "my-李磊3")
	//
	//fmt.Printf("myUsers len:%d\n", len(myUsers))
	//fmt.Printf("myUsers cap:%d\n", cap(myUsers))

	//b := [4]int{1, 2, 3, 4}
	//var sliceArr []int
	//sliceArr = b[:]
	//fmt.Println(sliceArr)
	////原数组下标1更改=30
	//b[1] = 30
	//fmt.Println(sliceArr)
	//
	//fmt.Printf("len->%d,cap-->%d\n", len(sliceArr), cap(sliceArr))
	//
	//sliceArr = append(sliceArr, 10, 11, 12)
	//fmt.Printf("扩容后 ：len->%d,cap-->%d\n", len(sliceArr), cap(sliceArr))
	//b[2] = 13
	//fmt.Println(sliceArr)

	var myMap map[string]string
	myMap = make(map[string]string, 3)

	myMap["李磊"] = "河南"
	myMap["小明"] = "北京"
	myMap["小花"] = "上海"
	myMap["小丽"] = "云南"

	fmt.Printf("长度-->%d", len(myMap))

	for name, dir := range myMap {
		fmt.Printf("名字%s地区%s\n", name, dir)
	}

	delete(myMap, "小丽")

	fmt.Println("----------")

	for name, dir := range myMap {
		fmt.Printf("名字%s地区%s\n", name, dir)
	}

	fmt.Println("----------")
	//遍历数组
	str := [...]string{"a", "b", "c", "d"}

	fmt.Printf("数组%#v\n", str)
	for index, value := range str {
		fmt.Printf("数组下标%d,数组的值%s \n", index, value)
	}
	fmt.Println("---------")
	//遍历切片
	strSlice := str[:]

	fmt.Printf("切片%#v\n", strSlice)
	for index, value := range strSlice {
		fmt.Printf("切片下标%d,切片的值%s \n", index, value)
	}

	//切片的删除

	var newSlice []string

	//(1)删除方式
	newSlice = append(strSlice[0:1], strSlice[2:]...)

	fmt.Println(newSlice)
	////(2)删除下标为1的
	//
	//for i := 0; i < len(strSlice); i++ {
	//	if i == 1 {
	//		continue
	//	}
	//	newSlice = append(newSlice, strSlice[i])
	//}
	//
	//fmt.Println("newSlice:", newSlice)

}
